Repository navigation
Make Ractor-compatible - #344
Merged
Merged
Conversation
Contributor
|
@jhawthorn This PR does not include tests for Ractor, so please add them.
|
Previously this was using class variables, however this module isn't included anywhere, so we might as well just use plain ivars
The @@available_functions class-variable wasn't frozen (to allow runtime methods to be added). I should be as fast to check for method_defined?(name, false), though this requires Ruby 2.6
This fixes a FrozenError on Ruby 2.6/2.7. On Ruby 3.0+ interpolated strings are always unfrozen
Member
Author
|
@naitoh Sorry for the delay! This has been rebased and I've added a couple tests of Ractors. The Ractor tests only run on Ruby 4.0+, as there are known issues on earlier versions (though the tests should pass as far back as 3.1, they might be flaky) |
This _should_ work, but for some reason is hanging (observed on HEAD w/ windows-latest)
Member
Author
|
This was hanging on windows CI (not sure why, almost certainly an upstream bug we should look into) so I skipped windows with the new tests for now. |
Contributor
|
Thanks! |
julik
added a commit
to guerilla-di/tracksperanto
that referenced
this pull request
Oct 2, 2026
Importers, exporters and tools no longer depend on anything a non-main Ractor can't touch: * The format registries and tool parameters are frozen arrays which get replaced on registration instead of mutated * Casts, Safety, Mux and Crop generate methods from strings instead of define_method with a block * Constants are made shareable via the shareable_constant_value magic comment, computed ones get frozen explicitly * progressive_io 2.x replaces 1.x, which is built on DelegateClass(IO) test/test_ractor_smoke.rb converts 16 fixtures across all importers, each in its own Ractor, through the full pipeline with tools and all exporters, and compares against a main-Ractor run. Ruby 4.0+ only, since Tempfile.new is unusable from non-main Ractors before that. REXML comes from git master until the Ractor fix in ruby/rexml#344 is released. CI now also runs on Ruby 3.4 and 4.0. Bump to 4.3.0. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
julik
added a commit
to guerilla-di/tracksperanto
that referenced
this pull request
Oct 5, 2026
* Make Tracksperanto usable from within Ractors Importers, exporters and tools no longer depend on anything a non-main Ractor can't touch: * The format registries and tool parameters are frozen arrays which get replaced on registration instead of mutated * Casts, Safety, Mux and Crop generate methods from strings instead of define_method with a block * Constants are made shareable via the shareable_constant_value magic comment, computed ones get frozen explicitly * progressive_io 2.x replaces 1.x, which is built on DelegateClass(IO) test/test_ractor_smoke.rb converts 16 fixtures across all importers, each in its own Ractor, through the full pipeline with tools and all exporters, and compares against a main-Ractor run. Ruby 4.0+ only, since Tempfile.new is unusable from non-main Ractors before that. REXML comes from git master until the Ractor fix in ruby/rexml#344 is released. CI now also runs on Ruby 3.4 and 4.0. Bump to 4.3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Work with frozen string literals The Shake lexer appends to its atom buffer, which was an empty string literal - use a mutable buffer instead. All library files get the frozen_string_literal magic comment, and the two tests which collect progress messages into string literals use mutable strings. Require tickly 2.2.1, which fixes the same problem in its parser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bring the change summary up to date Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Require the released obuf 1.3.1 and flame_channel_parser 4.2.1 These carry the frozen_string_literal changes, so the versions we test against are the ones we ask for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update the open items in the change summary Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For the most part this just involved freezing Strings or other constants. I tried to aim for the best final state rather than workarounds, so let me know if any changes are desired/anything is too aggressive ❤️. Where possible I changed to
frozen_string_literal: trueinstead of simply freezing the required constants.Two more significant changes are:
FunctionsClassto usemethod_defined?(x, false)instead of maintaining a mutable hash. This required bumping to Ruby 2.6REXML::Securityto use ivars instead of cvars. This module wasn't included anywhere internally so it should work the same. (Ruby 4.1+ will allow cvars to be read from Ractors so this change was only necessary for earlier/current versions, but I think it's faster and better anyways)